package com.itheima.test;

import java.util.ArrayList;

public class StudentTest2 implements StudentService {

    @Override
    public void printAllInfo(ArrayList<Student> students) {
        int boysCount=0;
        int girlsCount=0;
        for (int i = 0; i < students.size(); i++) {
            System.out.println("----------全班全部学生信息如下--------------");

                Student e=students.get(i);
                e.toString();
                if (e.getGender()=='男'){
                    boysCount++;
                }
                else {
                    girlsCount++;
                }



        }
        System.out.println("男生人数是：" + boysCount + ", 女士人数是：" +girlsCount);
        System.out.println("班级总人数是：" + students.size());
        System.out.println("-----------------------------------------");
    }

    @Override
    public void printAverageScore(ArrayList<Student> students) {
        double max=students.get(0).getScore();
        double min=students.get(0).getScore();
        double allScore=0.0;
        for (int i = 0; i < students.size(); i++) {
            allScore+=students.get(i).getScore();
            if (max<students.get(i).getScore()){
                max=students.get(i).getScore();
            }if (min>students.get(i).getScore()){
                min=students.get(i).getScore();
            }

        }

        System.out.println("学生的最高分是：" + max);
        System.out.println("学生的最低分是：" + min);
        System.out.println("平均分：" + (allScore - max - min) / (students.size() - 2));
    }
}
